<template>
  <div style="width: 100%;" class="mt24">
    <t-form :data="formData" :rules="rules" ref="form" label-align="top">
      <t-form-item label="是否允许分享" name="share_status">
        <t-switch v-model="formData.share_status" :label="['允许', '禁止']" :custom-value="[1, 0]" />
      </t-form-item>
      <t-form-item label="分享图片" name="share_image">
        <upload-img module="product" :value="[{url: formData.share_image}]" @success="handleSuccess($event, 'share_image')"></upload-img>
      </t-form-item>
      <t-form-item label="分享标题" name="share_title">
        <t-input v-model="formData.share_title" placeholder="请输入分享标题"></t-input>
      </t-form-item>
      <t-form-item label="分享描述" name="share_desc">
        <t-input v-model="formData.share_desc" placeholder="请输入分享描述"></t-input>
      </t-form-item>
    </t-form>
  </div>
</template>

<script>

import UploadImg from "@/components/upload-img/index.vue";

export default {
  name: 'DepositSetting',
  components: {UploadImg},
  props: {
    value: {
      type: String,
      default: ''
    },
  },
  data() {
    return {
      editorOption: {},
      formData: {
        share_status: 1, // 是否允许分享
        share_title: '', // 分享标题
        share_desc: '', // 分享描述
        share_image: '', // 分享图片
      },
      rules: {
        //share_status: [{required: true, message: '请选择是否允许分享', trigger: 'change'},],
        //share_title: [{required: true, message: '请输入分享标题', trigger: 'change'},],
        //share_desc: [{required: true, message: '请输入分享描述', trigger: 'change'},],
        //share_image: [{required: true, message: '请上传分享图片', trigger: 'change'},],
      }
    }
  },
  mounted() {
  },
  methods: {
    reset() {
      this.formData = {
        share_status: 1, // 是否允许分享
        share_title: '', // 分享标题
        share_desc: '', // 分享描述
        share_image: '', // 分享图片
      }
      this.$refs.form.reset()
    },
    submit() {
      return  this.$refs.form.validate()
    },
    handleSuccess(files, key) {
      this.formData[key] = files.response.url
    }
  }
}
</script>

<style lang="less" scoped>

</style>
